//引入axios实例
import request from "@/utils/request"


//请求商品分页列表返回值中records的每一项类型
export interface reqGoodsValue {
    id: number,
    tmName: string,
    logoUrl: string
}
//请求商品分页列表返回值中records的类型
export type reqGoodsRecodesType = reqGoodsValue[]
//请求商品分页列表的返回值类型
export interface reqGoodsReturn {
    records: reqGoodsRecodesType
    total: number,
    size: number,
    current: number,
    searchCount: boolean,
    pages: number
}
//1.请求商品分页列表
export const requestGetGoodsList = (page: number, limit: number) => {
    return request.get<any , reqGoodsReturn>(`/admin/product/baseTrademark/${page}/${limit}`)
}

//新增商品请求的参数类型
export interface reqAddGoodsParamsType {
    id?: number,
    logoUrl: string,
    tmName: string
}
//2.新增商品
export const requestAddGoods = (newGood: reqAddGoodsParamsType) => {
    return request.post<any , null>(`/admin/product/baseTrademark/save` , newGood)
}

//新增商品请求的参数类型
export interface reqUpdateGoodsParamsType {
    id: number,
    logoUrl: string,
    tmName: string
}
//3.修改商品
export const requestUpdateGoods = (newGood: reqUpdateGoodsParamsType) => {
    return request.put<any , null>(`/admin/product/baseTrademark/update` , newGood)
}

//4.删除商品
export const requestDeleteGoods = (id: number) => {
    return request.delete<any , null>(`/admin/product/baseTrademark/remove/${id}`)
}

//5.获取所有品牌列表
export interface TmListType {
    id: number;
    tmName: string;
    logoUrl: string;
}
export const requestAllTmList = () => {
    return request.get<any, TmListType[]>(
        `/admin/product/baseTrademark/getTrademarkList`
    );
};